package com.nidu.demo.common.enums;

import com.nidu.demo.common.validation.IntArrayValuable;
import cn.hutool.core.util.ArrayUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 邮件发送状态枚举
 *
 * @author auto
 */
@Getter
@AllArgsConstructor
public enum MailSendStatusEnum implements IntArrayValuable {
    
    INIT(0, "初始化"),
    SUCCESS(1, "发送成功"),
    FAILURE(2, "发送失败");

    private final Integer value;
    private final String desc;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(MailSendStatusEnum::getValue).toArray();

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static MailSendStatusEnum of(Integer val) {
        return ArrayUtil.firstMatch(o -> o.getValue().equals(val), values());
    }
}

